package com.kayo.specimen.service;

import com.kayo.specimen.dao.PrivilegeMapper;
import com.kayo.specimen.model.Privilege;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.UUID;

@Service
public class PrivilegeServiceImpl implements PrivilegeService {
    @Autowired
    private PrivilegeMapper privilegeMapper;

    @Override
    public List<Privilege> getPrivileges(String id, String name, String url, String dependentId,String order) {
        return privilegeMapper.select(id, name, url, dependentId,order);
    }

    @Override
    public int addPrivileges(Privilege... privileges) {
        for (Privilege privilege : privileges) {
            privilege.setId(UUID.randomUUID().toString());
        }
        return privilegeMapper.insert(privileges);
    }

    @Override
    public int updatePrivileges(Privilege... privileges) {
        return privilegeMapper.update(privileges);
    }

    @Override
    public int removePrivileges(String... privilegeId) {
        return privilegeMapper.delete(privilegeId);
    }
}
